home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 21
/
Cream of the Crop 21 (Terry Blount) (October 1996).iso
/
utility
/
s48v13.zip
/
S48.DOC
< prev
Wrap
Text File
|
1996-07-23
|
24KB
|
432 lines
▄██████▄ ▄██▀ ▄██████▄
███ ███ ▄██▀ ███ ███
███▄▄▄▄ ▄██▀ ▄▄▄ ▀██▄▄██▀
▀▀▀▀███ ███▄▄███ ▄██▀▀██▄
███ ███ ▀▀▀▀▀███ ███ ███
▀██████▀ ███ ▀██████▀
A Full Screen Simulator for 8048 Compatible Microprocessors
Version 1.3
William Luitje
23 July 1996
┌─────────────────────────────────────────────────────────────────┐
│▒▒▒ Background ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
└─────────────────────────────────────────────────────────────────┘
I wrote this simulator as part of my work on a consulting job a
few years ago. There is still quite a lot of work one could do
to improve it, such as providing a way to manually change RAM and
ports, allowing disassembly of any part of ROM, simulating
changes in inputs, command files... A LOT! Still, I think it's
useful, as is, for learning the 8048 instruction set and
debugging small programs. I hope it's useful to you; if you use
it, please see the registration section at the end of this
document (relax, no money is involved).
With the work I mentioned above and some features specifically
for an educational environment, this program would make a great
tool for teaching microprocessor programming. Commercial
programs like this cost from US$200 to $300. If I make an educa-
tional version of S48, I envision a site licensing arrangement
which would cost a very modest amount per student. If you are an
instructor or administrator and are interested in pursuing this,
contact me at the address given at the end of this document even
if you use a different micro in your course.
┌─────────────────────────────────────────────────────────────────┐
│▒▒▒ Introduction ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
└─────────────────────────────────────────────────────────────────┘
S48 simulates the instruction set and some of the hardware for
the 8048, 8049, 8050, 8021, 8022 microprocessors originated by
Intel and now widely second-sourced. The simulator handles these
hardware parameters:
■ 4096 bytes of ROM
■ 128 bytes of internal RAM
■ 256 bytes of external RAM
■ 7 I/O ports
■ one 8 bit timer
The hardware registers and flags and RAM are continuously
displayed on screen and are updated as each instruction is
executed. There is a disassembly window showing the instructions
as they are executed. You can trace through instructions one at
a time or execute them continuously until a breakpoint is reached
or you stop the program manually.
The hardware requirements to run S48 are quite simple; you'll
need a PC with a monochrome, Hercules, CGA, EGA, or VGA
compatible video card (the program does direct screen writes so
you'll see snow using CGA). A color display is not strictly
necessary, but is certainly helpful in reading the screen easily.
Obviously, the faster your CPU, the faster the simulation will
run. A 4.77 MHz PC is adequate for small programs. The software
requirements are even simpler: you'll need some version of DOS,
S48 and an 8048 program to simulate.
┌─────────────────────────────────────────────────────────────────┐
│▒▒▒ Sample Program ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
└─────────────────────────────────────────────────────────────────┘
I've included a very simple sample program for you to play with,
called demo.bin. demo.asm is the source file and implements a 16
bit counter in software. There is an interrupt service routine
which captures the low byte of that counter and stores it in
consecutive locations in external RAM when the interrupt is
invoked. The timer interrupt service routine increments an 8 bit
counter when the timer overflows. It's short enough that I can
reproduce its assembly listing here:
.org 0
0000 00 nop
0001 04 09 jmp start
0003 .org 3
0003 00 nop
0004 00 nop
0005 04 1B jmp intsvc
0007 .org 7
0007 04 21 jmp tmrsvc
0009 ; Initialization
0009 27 start clr a
000A A8 mov r0,a
000B A9 mov r1,a
000C AB mov r3,a
000D 62 mov t,a
000E B8 18 mov r0,#24
0010 A0 mov @r0,a
0011 25 en tcnti
0012 55 strt t
0013 05 en i
0014 ; Main Loop
0014 18 loop inc r0
0015 F8 mov a,r0
0016 96 14 jnz loop
0018 19 inc r1
0019 04 14 jmp loop
001B ; External Interrupt Service Routine
001B F8 intsvc mov a,r0
001C D5 sel rb1
001D 90 movx @r0,a
001E 18 inc r0
001F C5 sel rb0
0020 93 retr
0021 ; Timer Overflow Interrupt Service Routine
0021 1B tmrsvc inc r3
0022 93 retr
0023 .end
You'll also need an understanding of the 8048 instruction set and
architecture. You won't find much help in this document.
┌─────────────────────────────────────────────────────────────────┐
│▒▒▒ Tutorial ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
└─────────────────────────────────────────────────────────────────┘
The 8048 program to be executed can be in either Intel hex format
or binary, like you would use to program an EPROM. The simulator
tries to read the file in hex format first and if that fails
assumes that the file is binary. To invoke the simulator, just
give the name of the program file as an argument, e.g.:
s48 demo.bin
Take a minute to familiarize yourself with the layout of the
screen:
┌────────────────────────────────────────────────────────────────────────────┐
│Cmd: │
│ 35 bytes read from demo.bin │
│┌─PC┐ ┌A─┐┌PSW┬CY┬AC┬F0┬F1┬RB┬STK┐TIE┬TS┬TF┬TM┐ │
│└000┘ └ ┘└─08┴─ ┴─ ┴─0┴─0┴─0┴──0┘└─0┴─0┴00┴ ┘ │
│ ┌MB┐ ┌Bus┐┌P1┬P2┬P3┬P4┬P5┬P6┬P7┐ ┌T0┬T1┬II┬IE┐ │
│ └─0┘ └─ ┘└ ┴ ┴ ┴ ┴ ┴ ┴ ┘ └─ ┴─ ┴─ ┴─ ┘ │
│ ╔═00══10══20══30══40══50══60══70═══╗ ▒000▒00▒▒▒▒NOP▒▒▒▒▒▒▒ │
│ 00 ║ ░░ ║ 08 001 04 06 JMP 006 │
│ 01 ║ ░░ ║ 09 003 00 NOP │
│ 02 ║ ░░